<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>生命周期函数</title>
  <script src="./vue.js"></script>
</head>
<body>
  <div id="root">
  </div>
  <script>
    var vm = new Vue({
      el: '#root',
      template: '<div>{{test}}</div>',
      data: {
        test:'hello'
      },
      beforeCreate: function() { // 第一次初始化之后
        console.log('beforeCreate');
      },
      created: function() { // 第二次初始化之后
        console.log('created');
      },
      beforeMount: function() { // 模版和数据结合后，页面挂载前
        console.log(this.$el);
        console.log('beforeMont');
      },
      mounted: function() { // 页面挂载后
        console.log(this.$el);
        console.log('mounted'); 
      },
      beforeUpdate: function() { // 数据更新前
        console.log('beforeUpdate');
      },
      updated: function() { // 数据更新后
        console.log('updated');
      },
      beforeDestroy: function() {
        console.log('beforeDestroy');
      },
      destroyed: function() {
        console.log('destroyed');
      }
    })
  
  </script>
</body>
</html>